﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static _79委托的练习.Program;

namespace _79委托的练习
{
    class Person
    {

        

        public string name;
        public int presCont = 10;
        public List<string> list = new List<string>();

        Random ran = new Random();

        public Person()
        {
            list.Add("鱼香肉丝");
            list.Add("宫保鸡丁");
            list.Add("黄焖鸡");
            list.Add("过油肉");
            list.Add("水煮牛肉");
            list.Add("回锅肉");
            list.Add("蛋花汤");
            list.Add("剁椒鱼头");
            list.Add("西红柿炒鸡蛋");
            list.Add("猪肉炖粉条");
        }

        //喂养宠物
        public void eatAnima(PersonDe d)
        {
            eat();
            //如果还有食物,给宠物喂食
            if (list.Count > 0)
            {
                d();
            }
        }

        //吃饭消耗食物
        public void eat()
        {
            if (list.Count > 0)
            {
                    list.RemoveAt(0);
                    presCont++;
                    Console.WriteLine(name + "吃掉了"+list[0]);
            }
        }

        //工作获得食物
        public void work()
        {
            if(presCont > 0)
            {
                presCont--;                
                int rNbumber = ran.Next(0, 9);
                list.Add(list[rNbumber]);
                Console.WriteLine("通过工作获得了："+list[rNbumber]);
                
            }
        }
    }
}
